<template>
  <div>
    <s-table
      bordered
      ref="table"
      :row-key="(record,index) => index"
      :columns="callTimeColumns"
      :data="callData"
    >
      <template slot="call_time" slot-scope="text,record">
        <a-tag color="red" v-if="activeKey == 1">
          {{(record.by_ts/60).toFixed(2)}}
        </a-tag>
        <a-tag color="red" v-if="activeKey == 2">
          {{(record.sy_ts/60).toFixed(2)}}
        </a-tag>
      </template>
    </s-table>
  </div>
</template>

<script>
import { STable } from '@/components'
import col from '@/columns/group'
import { getCallList } from '@/api/calls'

export default {
  components: {
    STable
  },
  name: 'CallTime',
  data () {
    return {
      callTimeColumns: col.call_time,
      callData: parameters => {
        return getCallList(Object.assign(parameters, this.queryParam)).then(res => {
          return res.result
        })
      },
      queryParam: {}
    }
  },
  created () {
    this.queryParam['filter[adviser_name]'] = this.$route.params.id
    this.queryParam['filter[type]'] = 2
  },
  activated () {
    this.$refs.table.refresh(true)
  },
  methods: {
    onChange (e) {
      this.queryParam['type'] = e.target.value
      this.$refs.table.refresh(true)
    }
  }
}
</script>

<style scoped>

</style>
